<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/public/header.jsp"%>
<%
	String finance_company_id = request.getParameter("finance_company_id") == null ? "" : request.getParameter("finance_company_id");
%>
<html>
	<head>
		<title>公司账户日志</title>
	</head>
	<script type="text/javascript">
		$(function(){
			$('#table').datagrid({
				title:'账户往来明细',
				rownumber:true,
				url:'<%=contextPath %>/springMVC/finance/listPageFinanceCompanyLog?finance_company_id=<%=finance_company_id%>', 
				loadMsg:'正在加载数据，请稍后......',
				fitColumns:true,
				nowrap:false,
				columns:[[
					{title:'id',field:'id',hidden:true},
					{title:'时间',field:'operation_date',width:200,align:'center'},
					{title:'摘要',field:'summary',width:300,align:'center'},
					{title:'类别',field:'type',width:50,align:'center',formatter:function(value,row,index){
						if(value == "1")
						{
							return "<img src='<%=contextPath %>/public/easyui1.4/themes/icons/receive.gif'  title='收入'/>";
						}
						if(value == "2")
						{
							return "<img src='<%=contextPath %>/public/easyui1.4/themes/icons/zc.gif'  title='支出'/>";
						}
						return "";
					}},
					{title:'交易前金额',field:'before_money',width:200,align:'center',formatter:function(value,row,index){
						if(row.type == '0'){
							return "";
						}else{
							return value;
						}
					}},
					{title:'本次发生额',field:'money',width:200,align:'center'},
					{title:'交易后余额',field:'afterMoney',width:200,align:'center',formatter:function(value,row,index){
						if(row.type == '0'){
							return row.money;
						}
						if(row.type == '1'){
							return Math.round((parseFloat(row.before_money)+parseFloat(row.money))*Math.pow(10,2))/Math.pow(10,2);
						}
						if(row.type == '2'){
							return Math.round((parseFloat(row.before_money)-parseFloat(row.money))*Math.pow(10,2))/Math.pow(10,2);
						}
					}}
				]],
				pageSize:10,
				pageList : [10,50,100],  
				pagination:true,
				onLoadSuccess:function(rtJson){
					if(rtJson.rtState== '1')
					{
						warningInfo(rtJson.rtMsrg);
					}
				}
			});
			//----end
		});
		function doSearch(){
			var start_date = $('#start_date').datebox('getValue');
			var end_date = $('#end_date').datebox('getValue');
			$('#table').datagrid('load',{
				start_date:start_date,
				end_date:end_date,
				finance_company_id:'<%=finance_company_id%>'
			});
		}

		//弹出警告框信息
		function warningInfo(msg){
			jQuery.messager.alert('提示：',msg);
		}
		function ExcelOut(){
			var start_date = $('#start_date').datebox('getValue');
			var end_date = $('#end_date').datebox('getValue');
			window.open('<%=contextPath %>/springMVC/excel/financeCompanyLogExcel?finance_company_id=<%=finance_company_id%>'+"&start_date="+start_date+"&end_date="+end_date);
		}
	</script>
	<body>
		    	    <div id="table"  data-options="fit:true,toolbar:'#queryParamDiv'"></div>  
		    	    <div id="queryParamDiv" style="padding:3px;height:auto">
						<div align="right">
							开始日期: <input id="start_date" name="start_date" class="easyui-datebox" />
							结束日期: <input id="end_date" name="end_date" class="easyui-datebox" />&nbsp;&nbsp;
							<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="doSearch();">搜索</a>
							<input type='button'  style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-excel' title='导出Excel' onclick='ExcelOut()'/>
						</div>
					</div>
	</body>
</html>
